Skip to content

Conversation

@TomNicholas
Copy link
Member

@TomNicholas TomNicholas commented Sep 6, 2025

Proposal for how to close #1208.

With this we get

In [1]: import icechunk
   ...: 
   ...: storage = icechunk.in_memory_storage()
   ...: repo = icechunk.Repository.create(storage)

In [2]: repo.readonly_session("main")
Out[2]: 
<icechunk.Session>
read_only: True
snapshot_id: 1CECHNKREP0F1RSTCMT0

In [3]: repo.writable_session("main")
Out[3]: 
<icechunk.Session>
read_only: False
snapshot_id: 1CECHNKREP0F1RSTCMT0
branch: main
has_uncommitted_changes: False

For compound classes I want to have them make nested repr calls, i.e. Repository.__repr__ includes RepositoryConfig.__repr__ and Storage.__repr__, passed as "attributes". This way we should be able to have nice nested reprs for all classes be implemented simply and consistently. It should also be easy to change the reprs if necessary, or to match any API changes later.

Then once that's done we can use the same approach but for HTML reprs in a follow-up PR.

@TomNicholas TomNicholas added documentation 📝 Improvements or additions to documentation python 🐍 Related to python code labels Sep 6, 2025
@TomNicholas TomNicholas marked this pull request as draft September 6, 2025 01:37
Copy link
Collaborator

@paraseba paraseba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm OK with this. But the reason why I'd prefer to write it in Rust is because of all the tests we would need if we do it in python. If we change the name read_only to readonly things break, in Rust we would get a compilation error.

@TomNicholas
Copy link
Member Author

But the reason why I'd prefer to write it in Rust is because of all the tests we would need if we do it in python. If we change the name read_only to readonly things break, in Rust we would get a compilation error.

That's fair. Closing this in favour of the rust implementation in #1217.

@TomNicholas TomNicholas deleted the python-reprs-in-python branch September 10, 2025 00:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation 📝 Improvements or additions to documentation python 🐍 Related to python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nicer python reprs (string and HTML)

2 participants